<template>
  <MenuNavigation />
  <div
    class="exhibits-box jy-style-height"
    id="exhibits-box-id"
    :style="{
      background: `url(${publicUrls + 'free/style9/publicStyle9Bg.png' + '?imageView2/3/format/webp'})`,
    }"
  >
    <div class="top-box">
      <div class="back-box" @click="blankHome">
        <div class="line-box"></div>
        <div class="circle-box"></div>
        <p class="back-text">返回</p>
      </div>
      <div class="title">文创商品</div>
      <div class="screen-layout"></div>
    </div>
    <ScrollBoxCom
      color="rgba(50, 43, 37, 1)"
      v-if="Scrollwidth"
      :byid="986761"
      :width="getScrollWidth"
      :checkHeight="true"
      :scroll-src="publicUrls + 'free/style9/scrollIcon.png'"
    >
      <template #solidBorderExcon>
        <div
          class="right-scroll"
          ref="scrollBox"
          :style="list?.length <= 4 && { justifyContent: 'center', paddingLeft: '0px', width: '100%' }"
        >
          <div class="is-null" v-if="list.length === 0 && !loading"><span>暂无文创商品</span></div>
          <!-- <div class="is-null" v-if="list.length === 0 && !loading"><span>暂无文创商品</span></div> -->
          <div class="item-parent" v-for="(item, index) in list" :key="item.id">
            <div class="item" :class="{ 'item-1': index === 0, 'item-max': index === list.length - 1 }">
              <div class="item-img-box" @click="pathLink(item.url)">
                <img
                  class="item-img t-image t-image--fit-cover t-image--position-center"
                  v-if="!item.coverUrl"
                  src="http://101.34.143.36:8890/api/image/387939155165253"
                  alt=""
                />
                <img
                  class="item-img t-image t-image--fit-cover t-image--position-center"
                  v-else
                  :src="$filters.getLinkUrl(item.coverUrl + '?imageView2/1/w/270/h/270/format/webp')"
                  alt=""
                />
              </div>
              <p class="item-name">{{ item.name }}</p>
              <div class="item-btm">
                <span class="item-title2" v-if="item.price">参考价</span>
                <span class="item-title1" v-if="item.price">￥</span>
                <span class="item-title1" v-if="item.price">{{ item.price }}</span>
                <span class="item-title2" v-if="!item.price">暂无价格</span>
              </div>
            </div>
          </div>
        </div>
      </template>
      <template #solidBorderExbar>
        <div class="solidBorder-child"></div>
      </template>
    </ScrollBoxCom>
    <div class="center-box">
      <div
        class="exhibits-bg"
        :style="{
          background: `url(${publicUrls + 'free/style9/exhibitsBg.png' + '?imageView2/3/format/webp'})`,
        }"
      ></div>
    </div>
    <div class="content-door">
      <i class="iconfonts">&#xe6dd;</i>
      <span>永不落幕的展览与展示平台</span>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style9',
});
</script>

<script setup lang="ts">
// @ts-nocheck
import MenuNavigation from '@/freeComponents/menuNavigation/index.vue';
import { publicUrls } from '@/utils/minxin';
import { goodsList } from '@/api/goods/goods';
import RightMenu from '../components/rightMenu.vue';
import Logo from '../components/logo.vue';
import FooterHome from '../components/footerHome.vue';
import PublicTitle from '../components/PublicTitle.vue';
import { useRouter, useRoute } from 'vue-router';
import ScrollBoxCom from '../scrollBox.vue';
import { ref, watch, reactive, nextTick, defineComponent } from 'vue';
import { copyrightSave, copyrightInfo } from '@/api/templates/templates';
import { useProjectStore, commonDataStore } from '@/store';
import { storeToRefs } from 'pinia';
import { computed } from 'vue';

const parmas = reactive({
  value: '',
  pageNo: 1,
  pageSize: 100,
});
const topShow = ref(false);
const scrollBox = ref(null);
const percentage = ref(0);
const list = ref([]);
const total = ref(0);
const loading = ref(false);
const store = useProjectStore();
const Scrollwidth = ref();
const router = useRouter();
const route = useRoute();
const Description = ref('');
const init = async () => {
  try {
    if (loading.value) {
      return;
    }
    loading.value = true;
    let res = await goodsList(localStorage.getItem('projectId'), parmas);
    total.value = res.data.total;
    list.value = list.value.concat(res.data.data);
    // list.value = [];
    loading.value = false;
  } catch {
    loading.value = false;
  }
};
init();

let viewportwidth = window.innerWidth;
Scrollwidth.value = (viewportwidth / 900) * 560;

const getScrollWidth = computed(() => {
  let widths = (window.innerWidth / 900) * 560;
  return widths;
});

const handleScroll = (event) => {
  event.preventDefault(); // 阻止默认滚动行为
  const { deltaY } = event;

  // 获取滚动内容的 DOM 元素
  const contentEl = scrollBox.value;

  // 将滚动盒子向前滚动
  contentEl.scrollLeft += deltaY;
  if (contentEl.scrollWidth > contentEl.clientWidth) {
    if (
      contentEl.scrollWidth < contentEl.scrollLeft + contentEl.clientWidth + 100 &&
      !loading.value &&
      list.value.length < total.value
    ) {
      parmas.pageNo = parmas.pageNo + 1;
      init();
    }
    nextTick(() => {
      const { scrollLeft, clientWidth, scrollWidth } = scrollBox.value;
      if (scrollLeft > 100) {
        topShow.value = true;
      }
      if (scrollLeft < 100) {
        topShow.value = false;
      }
      const newScrollPercentage = Math.floor((scrollLeft / (scrollWidth - clientWidth)) * 100);
      percentage.value = newScrollPercentage == 99 ? 100 : newScrollPercentage;
    });
  }
};
const emitTop = () => {
  //点击回到列表最左侧
  scrollBox.value.scrollLeft = 0;
  percentage.value = 0;
  topShow.value = false;
};
const pathLink = (url?: string) => {
  if (!url) {
    return;
  }
  window.open(url, '_blank');
};
const blankHome = () => {
  router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
};
</script>

<style lang="less" scoped>
.exhibits-box {
  position: relative;
  width: 100%;
  height: 100%;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  background-position: top center !important;
  padding: 40px 0;
}
.top-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 60px;
}
.back-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.line-box {
  flex-shrink: 0;
  width: 140px;
  height: 1px;
  background: #898172;
}
.circle-box {
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #898172;
}
.back-text {
  flex-shrink: 0;
  color: #898172;
  font-family: 'SourceHanSerifCN';
  font-size: 18px;
  font-style: normal;
  font-weight: 900;
  line-height: 160%; /* 28.8px */
  margin-left: 2px;
}
.title {
  flex-shrink: 0;
  color: #faeedc;
  text-align: center;
  font-family: 'SourceHanSerifCN';
  font-size: 36px;
  font-style: normal;
  font-weight: 900;
  line-height: 56px; /* 155.556% */
}
.screen-layout {
  width: 108px;
  height: 46px;
}
.center-box {
  position: absolute;
  bottom: 40px;
  left: 0;
  width: 100%;
  padding: 0 60px;
  margin-top: 24px;
}
.exhibits-bg {
  width: 100%;
  height: 740px;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
}
.content-door {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  bottom: 0;
  opacity: 0.5;
  .iconfonts {
    font-size: 26px;
    color: #fff;
    margin-bottom: 4px;
    line-height: 32px;
  }
  span {
    font-family: PingFang SC;
    font-size: 16px;
    line-height: 32px;
    color: #fff;
    margin-left: 20px;
    padding-bottom: 7px;
  }
}
::v-deep .unit-exbit-null-remarks-info {
  height: 740px !important;
  padding: 0 100px 0 100px;
}
.right-scroll {
  display: flex;
  padding-left: 50px;
  // width: 100%;
}
.is-null {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  span {
    font-size: 20px;
    line-height: 32px;
    color: rgba(79, 110, 92, 0.26);
    opacity: 0.5;
  }
}
.item-parent {
  height: auto;
  margin-right: 40px;
  cursor: pointer;
}
.item-img-box {
  padding: 16px;
  width: 290px;
  height: 360px;
  border-radius: 16px;
  border: 1px solid #faeedc;
  background: rgba(250, 238, 220, 0.3);
  box-shadow: 0px 0px 8px 0px rgba(170, 157, 141, 0.5);
}
.item-name {
  overflow: hidden;
  color: #333;
  text-align: center;
  text-overflow: ellipsis;
  font-family: 'MicrosoftYaHei';
  font-size: 18px;
  font-style: normal;
  font-weight: 400;
  line-height: 36px; /* 200% */
  text-indent: 0 !important;
  display: -webkit-box;
  width: 290px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  margin-top: 16px;
}
.item-btm {
  margin-top: 4px;
  display: flex;
  align-items: flex-end;
}
.item-title2 {
  flex-shrink: 0;
  display: flex;
  width: 38px;
  height: 34px;
  flex-direction: column;
  justify-content: flex-end;
  color: rgba(51, 51, 51, 0.5);
  text-align: center;
  font-family: 'PingFangSC';
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 24px; /* 200% */
  white-space: nowrap;
}
.item-title1 {
  flex-shrink: 0;
  color: #333;
  text-align: center;
  font-family: 'SourceHanSerifCN';
  font-size: 22px;
  font-style: normal;
  font-weight: 700;
  line-height: 34px; /* 154.545% */
}
::v-deep .solid-box-parent {
  // width: 1621.33px !important;
  margin-top: 60px;
  .solid-box {
    width: 100% !important;
  }
}
::v-deep .solidBorder-child {
  width: 100%;
  height: 2px !important;
  background-color: #b1a693;
  opacity: 0.6;
}
::v-deep .templatestyle1-scroll-box-tumb {
  img {
    width: 22px;
    height: 22px;
    margin-top: 5px;
    margin-left: 8px;
  }
}
</style>
